//
//  EngageController.m
//  coachmanage
//
//  Created by 众拳科技 on 2018/3/6.
//  Copyright © 2018年 众拳科技. All rights reserved.
//

#import "EngageController.h"
#import "PointClassViewController.h"
@interface EngageController ()
@property(nonatomic,weak)FreeUseView *freeUseView;
@end

@implementation EngageController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.view.backgroundColor = BackGroundColor;
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    
    
    [self createSubView];
}

#pragma mark 创建子视图
-(void)createSubView{
    
    //这里判断有没有登录 如果有登录的话 就显示添加品牌和场馆的页面
    //没有登录 就显示 免费使用的界面
    
    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
    
    Boolean isLogin = [userDefault boolForKey:@"isLogin"];
    
    if (isLogin) {
        
        self.navigationController.navigationBar.hidden = NO;
        self.title = @"约课";
        PointClassViewController *point = [PointClassViewController new];
        [self addChildViewController:point];
        [self.view addSubview:point.view];
        
        [point.view mas_remakeConstraints:^(MASConstraintMaker *make) {
            
            make.edges.mas_equalTo(self.view);
            
        }];

    }
    else{
        self.navigationController.navigationBar.hidden = YES;
        FreeUseView *freeUseView = [[FreeUseView alloc] initWithFrame:self.view.frame];
        [freeUseView.freeUseBtn addTarget:self action:@selector(goToLogin)forControlEvents:UIControlEventTouchUpInside];
        [freeUseView.loginBtn addTarget:self action:@selector(goToLogin)forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:freeUseView];
        self.freeUseView = freeUseView;
    }
    
    [self.freeUseView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.mas_equalTo(self.view).insets(UIEdgeInsetsMake(0, 0, 0, 0));
    }];
}

#pragma mark 已经登录 免费使用 创建品牌
-(void)freeUseClick{
    
//    NewBrandViewController *newBrandVC = [[NewBrandViewController alloc] init];
//
//    [self.navigationController pushViewController:newBrandVC animated:YES];
}

#pragma 没有登录 点击使用 去登录页面
-(void)goToLogin{
    
    LoginViewController *loginVC = [[LoginViewController alloc] init];

    UserNavigationController *naVC = (UserNavigationController *)self.navigationController;

    naVC.isLoginNav= YES;

    [naVC pushViewController:loginVC animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
